package com.shanzmoo.db.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.shanzmoo.db.order.entity.OutletOrderDetailEntity;
import com.shanzmoo.db.order.mapper.OutletOrderDetailMapper;
import com.shanzmoo.db.order.service.IOutletOrderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 门店订单明细 服务实现类
 * </p>
 *
 * @author Gzhao
 * @since 2020-12-14
 */
@Service
public class OutletOrderDetailServiceImpl extends ServiceImpl<OutletOrderDetailMapper, OutletOrderDetailEntity>
        implements IOutletOrderDetailService {

    @Override
    public List<OutletOrderDetailEntity> getDetailByOrderNo(String orderNo) {
        return baseMapper.selectList(
                new QueryWrapper<OutletOrderDetailEntity>()
                        .eq("deleted", false)
                        .eq("order_no", orderNo)
        );
    }

    @Override
    public void deleteByOrderNo(String orderNo) {
        OutletOrderDetailEntity updateEntity = new OutletOrderDetailEntity();
        updateEntity.setDeleted(true);

        baseMapper.update(
                updateEntity,
                new UpdateWrapper<OutletOrderDetailEntity>()
                        .eq("deleted", false)
                        .eq("order_no", orderNo)
        );
    }
}
